package com.ylsf.blog.controller;

import com.ylsf.blog.service.DeleteService;
import com.ylsf.blog.service.impl.DeleteServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 删除控制类
 */
@WebServlet("/delete")
public class DeleteServlet extends HttpServlet {
    private DeleteService deleteService=new DeleteServiceImpl();
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setCharacterEncoding("UTF-8");
        String articleId = request.getParameter("articleId");
        boolean flag = deleteService.deleteArticle(articleId);
        if(flag){
            response.getWriter().print("删除成功");
        }else {
            response.getWriter().print("删除失败");
        }

    }
}
